package gui;

import factories.WorkingFileFieldFactory;
import initializers.Initializer;
import initializers.MenuBarInitializer;
import initializers.TabPaneInitializer;

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Panel;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import configuration.WindowSettings;

public class MainFrame extends AbstractMainFrame
{	
	private JTabbedPane tabbedPane = new JTabbedPane();
	private MenuBar menuBar = new MenuBar();
	private JPanel mainLayout = new JPanel(new FlowLayout());
	
	public MainFrame() 
	{
		setLookAndFeel(WindowSettings.LOOK_AND_FEEL_CLASS);
		
		mainFrame = new JFrame(WindowSettings.APPLICATION_NAME);
		JPanel jpanel = new JPanel();
		jpanel.setSize(300, 300);
		mainFrame.setContentPane(jpanel);
		initializeMainFrame();
	}
	
	protected void setInitializers()
	{
		initializers = new ArrayList<>();
		initializers.add(new TabPaneInitializer(tabbedPane));
		initializers.add(new MenuBarInitializer(this, menuBar));
	}

	protected void initialize() {
		for(Initializer<? extends Component> initializer : initializers)
		{
			Component component = initializer.initialize();
			if(component instanceof MenuBar)
			{
				mainFrame.setJMenuBar((JMenuBar) component);
			}
			else
			{
				mainFrame.getContentPane().add(component);
			}
			
		}
		
		workingFile = new WorkingFileFieldFactory().createWorkingFileFieldFactory();
		//mainFrame.getContentPane().add(workingFile);
	}
	
}
